package org.ISCS.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Data;

/**
 * 
 * @TableName instance
 */
@TableName(value ="instance")
@Data
public class Instance implements Serializable {
    /**
     * 实例id
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 实例ip
     */
    private String instanceIp;

    /**
     * 实例端口
     */
    private Integer instancePort;

    /**
     * 实例权重
     */
    private Double instanceWeight;

    /**
     * 实例元数据
     */
    private String instanceMetadata;

    /**
     * 所属服务id
     */
    private Long affilliateServiceId;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Instance other = (Instance) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getInstanceIp() == null ? other.getInstanceIp() == null : this.getInstanceIp().equals(other.getInstanceIp()))
            && (this.getInstancePort() == null ? other.getInstancePort() == null : this.getInstancePort().equals(other.getInstancePort()))
            && (this.getInstanceWeight() == null ? other.getInstanceWeight() == null : this.getInstanceWeight().equals(other.getInstanceWeight()))
            && (this.getInstanceMetadata() == null ? other.getInstanceMetadata() == null : this.getInstanceMetadata().equals(other.getInstanceMetadata()))
            && (this.getAffilliateServiceId() == null ? other.getAffilliateServiceId() == null : this.getAffilliateServiceId().equals(other.getAffilliateServiceId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getInstanceIp() == null) ? 0 : getInstanceIp().hashCode());
        result = prime * result + ((getInstancePort() == null) ? 0 : getInstancePort().hashCode());
        result = prime * result + ((getInstanceWeight() == null) ? 0 : getInstanceWeight().hashCode());
        result = prime * result + ((getInstanceMetadata() == null) ? 0 : getInstanceMetadata().hashCode());
        result = prime * result + ((getAffilliateServiceId() == null) ? 0 : getAffilliateServiceId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", instanceIp=").append(instanceIp);
        sb.append(", instancePort=").append(instancePort);
        sb.append(", instanceWeight=").append(instanceWeight);
        sb.append(", instanceMetadata=").append(instanceMetadata);
        sb.append(", affilliateServiceId=").append(affilliateServiceId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}